package com.apache.funds.service.plugins;

import com.apache.api.manager.PluginConnector;
import com.apache.api.vo.ParamsVo;
import com.apache.api.vo.ResultEntity;
import com.apache.database.constant.Validator;
import com.apache.database.model.Page;
import com.apache.funds.entity.SvmVoucher;
import com.apache.funds.manager.SvmVoucherManager;
import com.apache.funds.util.Constants;

public class FundsDefaultLSPlugin implements PluginConnector {

	private SvmVoucherManager svmVoucherManager;

	public void setSvmVoucherManager(SvmVoucherManager svmVoucherManager) {
		this.svmVoucherManager = svmVoucherManager;
	}

	@Override
	public Object execute(ParamsVo vo) throws Exception {
		ResultEntity re = new ResultEntity();
		re.setResult("true");
		re.setMessage("查询失败");
		re.setEntity("false");
		String userId = String.valueOf(vo.getParams("userId"));
		if (Validator.isNull(userId)) {
			re.setMessage(Constants.Msg.F006+"userId不能为空");
			return re;
		}
		vo.setParams("pageSize", Validator.getDefaultStr(String.valueOf(vo.getParams("pageSize")), "10"));
		vo.setParams("pageIndex", Validator.getDefaultStr(String.valueOf(vo.getParams("pageIndex")), "1"));
		vo.setParams("userId", userId);
		vo.setMethodKey("UserVoucherList");
		SvmVoucher svmVoucher = new SvmVoucher();
		vo.setObj(svmVoucher);
		Page page = svmVoucherManager.getPageInfo(vo);
		if (null != page) {
			re.setEntity(page);
			re.setMessage(Constants.Msg.F000+"查询成功");
		}
		return re;
	}
}
